
Namespace CAD

    Class BaseDatos

        Private Shared NombreServidor As String
        Private Shared NombreBaseDatos As String
        Private Shared NombreUsuarioBaseDatos As String
        Private Shared Contrasena As String
        Private Shared _conexion As SqlClient.SqlConnection
        Public Shared ReadOnly Property Conexion() As SqlClient.SqlConnection
            Get
                Return _conexion
            End Get

        End Property

        Public Shared Sub CrearConexion(ByVal CodigoCD As String)
            Select Case CodigoCD
                Case "BB01"
                    NombreServidor = "localhost"
                Case "BB02"
                    NombreServidor = "CBBEALPFAC1"
                Case "BB03"
                    NombreServidor = "CBBLPZPFAC1"
                Case "BB04"
                    NombreServidor = "CBBSCZPFAC1"
                Case "BB05"
                    NombreServidor = "CBBORUPFAC1"
                Case "BB06"
                    NombreServidor = "CBBSUCPFAC1"
 
            End Select

            NombreBaseDatos = "Kardex"
            NombreUsuarioBaseDatos = "sa"
            Contrasena = ""

            '_conexion = New SqlClient.SqlConnection("server=" + NombreServidor + "; database=" + NombreBaseDatos + ";User=" + NombreUsuarioBaseDatos + ";Pwd=" + Contrasena)
            _conexion = New SqlClient.SqlConnection("Data Source=192.168.111.128;Initial Catalog=kardex;User ID=sa;Password=sa")

        End Sub

        'Public CAD.BaseDatos.Conexion As New SqlClient.SqlConnection("server=COCHAPVEN1; database=SkyKardex;User=sa;Pwd=Sistemas007")

        Public Sub AbrirConexion()

            If _conexion.State = ConnectionState.Closed Then

                _conexion.Open()

            End If

        End Sub

        Public Sub CerrarConexion()

            If _conexion.State = ConnectionState.Open Then

                _conexion.Close()

            End If

        End Sub
    End Class

End Namespace
